home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / mint / mint96sb.zoo / src / proc.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-10-21  |  7.3 KB  |  214 lines

  1. /*
  2. Copyright 1990,1991,1992 Eric R. Smith. All rights reserved.
  3. */
  4.  
  5. /* proc.h: defines for various process related things */
  6. #ifndef _proc_h
  7. #define _proc_h
  8.  
  9. #include "file.h"
  10.  
  11. /* a process context consists, for now, of its registers */
  12.  
  13. typedef struct _context {
  14.     long    regs[15];    /* registers d0-d7, a0-a6 */
  15.     long    usp;        /* user stack pointer (a7) */
  16.     short    sr;        /* status register */
  17.     long    pc;        /* program counter */
  18.     long    ssp;        /* supervisor stack pointer */
  19.     long    term_vec;    /* GEMDOS terminate vector (0x102) */
  20. /*
  21.  * AGK: if running on a TT and the user is playing with the FPU then we
  22.  * must save and restore the context. We should also consider this for
  23.  * I/O based co-processors, although this may be difficult due to
  24.  * possibility of a context switch in the middle of an I/O handshaking
  25.  * exchange.
  26.  */
  27.     unsigned char    fstate[216];    /* FPU internal state */
  28.     long    fregs[3*8];    /* registers fp0-fp7 */
  29.     long    fctrl[3];    /* FPCR/FPSR/FPIAR */
  30. /*
  31.  * AGK: for long (time-wise) co-processor instructions (FMUL etc.), the
  32.  * FPU returns NULL, come-again with interrupts allowed primitives. It
  33.  * is highly likely that a context switch will occur in one of these if
  34.  * running a mathematically intensive application, hence we must handle
  35.  * the mid-instruction interrupt stack. We do this by saving the extra
  36.  * 3 long words and the stack format word here.
  37.  */
  38.     unsigned short    sfmt;    /* stack frame format identifier */
  39.     short    internal[42];    /* internal state -- see framesizes[] for size */
  40.     char    ptrace;        /* trace exception is pending */
  41. } CONTEXT;
  42.  
  43. #define PROC_CTXTS    2
  44. #define SYSCALL        0    /* saved context from system call    */
  45. #define CURRENT        1    /* current saved context        */
  46.  
  47. /*
  48.  * Timeout events are stored in a list; the "when" field in the event
  49.  * specifies the number of milliseconds *after* the last entry in the
  50.  * list that the timeout should occur, so routines that manipulate
  51.  * the list only need to check the first entry.
  52.  */
  53.  
  54. typedef struct timeout {
  55.     struct timeout *next;
  56.     struct proc    *proc;
  57.     long    when;
  58.     void    (*func) P_((struct proc *)); /* function to call at timeout */
  59. } TIMEOUT;
  60.  
  61. #ifndef GENMAGIC
  62. extern TIMEOUT *tlist;
  63. #endif
  64.  
  65. #define NUM_REGIONS    64    /* max. number of memory regions for a proc */
  66. #define MIN_HANDLE    (-5)    /* minimum handle number        */
  67. #define MIN_OPEN    6    /* 0..MIN_OPEN-1 are reserved for system */
  68. #define MAX_OPEN    32    /* max. number of open files for a proc    */
  69. #define SSTKSIZE    8000    /* size of supervisor stack (in bytes)     */
  70. #define ISTKSIZE    2000    /* size of interrupt stack (in bytes)    */
  71. #define STKSIZE        (ISTKSIZE + SSTKSIZE)
  72.  
  73. #define FRAME_MAGIC    0xf4a3e000UL
  74.                 /* magic for signal call stack */
  75. #define CTXT_MAGIC    0xabcdef98UL
  76. #define CTXT2_MAGIC    0x87654321UL
  77.                 /* magic #'s for contexts */
  78.  
  79. #define PNAMSIZ        8    /* no. of characters in a process name */
  80.  
  81. #define DOM_TOS        0    /* TOS process domain */
  82. #define DOM_MINT    1    /* MiNT process domain */
  83.  
  84. typedef struct proc {
  85. /* this is stuff that the public can know about */
  86.     long    sysstack;        /* must be first        */
  87.     CONTEXT    ctxt[PROC_CTXTS];    /* must be second        */
  88.  
  89.     long    magic;            /* validation for proc struct    */
  90.  
  91.     BASEPAGE *base;            /* process base page        */
  92.     short    pid, ppid, pgrp;
  93.     short    ruid;            /* process real user id     */
  94.     short    rgid;            /* process real group id     */
  95.     short    euid, egid;        /* effective user and group ids */
  96.  
  97.     ushort    memflags;        /* e.g. malloc from alternate ram */
  98.     short    pri;            /* base process priority     */
  99.     short    wait_q;            /* current process queue    */
  100.  
  101. /* note: wait_cond should be unique for each kind of condition we might
  102.  * want to wait for. Put a define below, or use an address in the
  103.  * kernel as the wait condition to ensure uniqueness.
  104.  */
  105.     long    wait_cond;        /* condition we're waiting on    */
  106.                     /* (also return code from wait) */
  107.  
  108. #define WAIT_MB        0x3a140001L    /* wait_cond for p_msg call    */
  109. #define WAIT_SEMA    0x3a140003L    /* wait_cond for p_semaphore    */
  110.  
  111.     /* (all times are in milliseconds) */
  112.     /* usrtime must always follow systime */
  113.     ulong    systime;        /* time spent in kernel        */
  114.     ulong    usrtime;        /* time spent out of kernel    */
  115.     ulong    chldstime;        /* children's kernel time     */
  116.     ulong    chldutime;        /* children's user time        */
  117.  
  118.     ulong    maxmem;            /* max. amount of memory to use */
  119.     ulong    maxdata;        /* max. data region for process */
  120.     ulong    maxcore;        /* max. core memory for process */
  121.     ulong    maxcpu;            /* max. cpu time to use     */
  122.  
  123.     short    domain;            /* process domain (TOS or UNIX)    */
  124.  
  125.     short    curpri;            /* current process priority    */
  126. #define MIN_NICE -20
  127. #define MAX_NICE 20
  128.  
  129. /* EVERYTHING BELOW THIS LINE IS SUBJECT TO CHANGE:
  130.  * programs should *not* try to read this stuff via the U:\PROC dir.
  131.  */
  132.  
  133.     char    name[PNAMSIZ+1];    /* process name            */
  134.     TIMEOUT    *alarmtim;        /* alarm() event        */
  135.     short    slices;            /* number of time slices before this
  136.                        process gets to run again */
  137.  
  138.     short    bconmap;        /* Bconmap mapping        */
  139.     FILEPTR *midiout;        /* MIDI output            */
  140.     FILEPTR *midiin;        /* MIDI input            */
  141.     FILEPTR    *prn;            /* printer            */
  142.     FILEPTR *aux;            /* auxiliary tty        */
  143.     FILEPTR    *control;        /* control tty            */
  144.     FILEPTR    *handle[MAX_OPEN];    /* file handles            */
  145.  
  146.     uchar    fdflags[MAX_OPEN];    /* file descriptor flags    */
  147.  
  148.     ushort    num_reg;        /* number of memory regions allocated */
  149.     MEMREGION **mem;        /* allocated memory regions    */
  150.     virtaddr *addr;            /* addresses of regions        */
  151.  
  152.     ulong    sigpending;        /* pending signals        */
  153.     ulong    sigmask;        /* signals that are masked    */
  154.     ulong    sighandle[NSIG];    /* signal handlers        */
  155.     ushort    sigflags[NSIG];        /* signal flags            */
  156.     ulong    sigextra[NSIG];        /* additional signals to be masked
  157.                        on delivery     */
  158.     char    *mb_ptr;        /* p_msg buffer ptr        */
  159.     long    mb_long1, mb_long2;    /* p_msg storage        */
  160.     long    mb_mbid;        /* p_msg id being waited for    */
  161.     short    mb_mode;        /* p_msg mode being waiting in    */
  162.     short    mb_writer;        /* p_msg pid of writer of msg    */
  163.  
  164.     short    curdrv;            /* current drive        */
  165.     fcookie root[NUM_DRIVES];    /* root directories        */
  166.     fcookie    curdir[NUM_DRIVES];    /* current directory        */
  167.  
  168.     long    usrdata;        /* user-supplied data        */
  169.     ushort    umask;            /* file creation mask        */
  170.  
  171.     DTABUF    *dta;            /* current DTA            */
  172. #define NUM_SEARCH    6        /* max. number of searches    */
  173.     DTABUF *srchdta[NUM_SEARCH];    /* for Fsfirst/next        */
  174.     DIR    srchdir[NUM_SEARCH];    /* for Fsfirst/next        */
  175.     long    srchtim[NUM_SEARCH];    /* for Fsfirst/next        */
  176.     
  177.     long    txtsize;        /* size of text region (for fork()) */
  178.  
  179.     long ARGS_ON_STACK (*criticerr) P_((long)); /* critical error handler    */
  180.     void    *logbase;        /* logical screen base        */
  181.  
  182.     struct proc *ptracer;        /* process which is tracing this one */
  183.     short    ptraceflags;        /* flags for process tracing */
  184.     short    starttime;        /* time and date when process    */
  185.     short    startdate;        /* was started            */
  186.  
  187.     struct    proc *q_next;        /* next process on queue    */
  188.     struct     proc *gl_next;        /* next process in system    */
  189.     char    stack[STKSIZE+4];    /* stack for system calls    */
  190. } PROC;
  191.  
  192.  
  193. /* different process queues */
  194.  
  195. #define CURPROC_Q    0
  196. #define READY_Q        1
  197. #define WAIT_Q        2
  198. #define IO_Q        3
  199. #define ZOMBIE_Q    4
  200. #define TSR_Q        5
  201. #define STOP_Q        6
  202. #define SELECT_Q    7
  203.  
  204. #define NUM_QUEUES    8
  205.  
  206. #ifndef GENMAGIC
  207. extern PROC *proclist;            /* list of all active processes */
  208. extern PROC *curproc;            /* current process        */
  209. extern PROC *rootproc;            /* pid 0 -- MiNT itself        */
  210. extern PROC *sys_q[NUM_QUEUES];        /* process queues        */
  211. #endif
  212.  
  213. #endif /* _proc_h */
  214.